package testing;


import static org.junit.Assert.*;

import io.ScannerTest;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

import org.junit.Before;
import org.junit.Test;


import plagiarism.CheckManager;

import checker.ArrayChecker;

import words.Article;
import words.ArticleResult;
import words.Comparer;
import words.Result;

public class testArticle {
	private String[] a1;
	private String[] a2;
	private ArrayList<String[]> arraylists;
	@Before
	public void setUp() throws Exception {
		
		Scanner s_a1 = new Scanner(new File("1.txt"));
		ArrayList<String> a1_list = new ArrayList<String>();
		while(s_a1.hasNext())
		{

			String temp = s_a1.next();
			a1_list.add(temp);
			
		}
		a1 = a1_list.toArray(new String[a1_list.size()]);
		/*
		Scanner s_a2 = new Scanner(new File("a2.txt"));
		ArrayList<String> a2_list = new ArrayList<String>();
		while(s_a2.hasNext())
		{

			String temp = s_a2.next();
			a2_list.add(temp);
			
		}
		a2 = a2_list.toArray(new String[a2_list.size()]);
		this.arraylists = new ArrayList<String[]>();
		this.arraylists.add(a1);
		this.arraylists.add(a2);
		*/
		
		//procedural testing
		this.arraylists = new ArrayList<String[]>();
		
		ScannerTest scannertest = new ScannerTest();
		scannertest.setfilename("passage1.txt");
		scannertest.run();
		this.arraylists.add(scannertest.getlist());
		
		scannertest.clear();
		scannertest.setfilename("passage2.txt");
		scannertest.run();
		this.arraylists.add(scannertest.getlist());
		scannertest.run();
	}
	/*
	@Test
	public void first()
	{
		CheckManager checkmanager = new CheckManager();
		checkmanager.operation(arraylists);
		checkmanager.checking();
		ArticleResult result = checkmanager.getArtResult(0);
		result.show_result();
		assertEquals(1,1);
		
	}
	@Test
	public void check_array()
	{
		boolean result;
		String[] array1  = new String[]{"I","am","him"};
		String[] array2  = new String[]{"I","am","him2"};
		ArrayList<String[]> array = new ArrayList<String[]>();
		array.add(array1);
		array.add(array2);
		
		ArrayChecker checker = new ArrayChecker();
		checker.set_origin(array);
		checker.set_compared(array);
		checker.compare();
		int num = checker.getCount();
		assertEquals(num,2);
	}
	*/

	@Test
	public void check_checker() {
		CheckManager checkmanager = new CheckManager();
		checkmanager.operation(this.arraylists);
		checkmanager.checking();
		checkmanager.output_all();

		assertEquals(1, 1);
	}
	@Test
	public void test_scanner()
	{

		assertEquals(1,1);
	}
}
